package com.life.controller;

import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

import com.life.model.IModelEventsListener;
import com.life.model.LifeModel;
import com.life.model.event.ModelBoardCompleteEvent;
import com.life.model.event.ModelBoardCreateEvent;
import com.life.model.event.ModelBoardResetEvent;
import com.life.model.event.ModelBoardRuleSetEvent;
import com.life.model.event.ModelBoardUpdateEvent;
import com.life.view.AbstractAdapter;

/**
 * Abstract controller 
 * @author HindsM
 *
 */
public abstract class AbstractController implements Observer, IModelEventsListener{
  
	LifeModel theModel = null;
	
	public AbstractController(LifeModel model, ArrayList<AbstractAdapter>adapterList)
	{
		theModel = model;
		if(adapterList != null)
		{
		for(Observable adapter:adapterList)
		{
			adapter.addObserver(this);
		}
		}
	}
	
	public LifeModel getModel() {
		return theModel;
	}


	public void setModel(LifeModel theModel) {
		this.theModel = theModel;
	} 
	
	public void update(Observable source, Object data)
	{
		doUpdate((AbstractAdapter)source,data);
	}
	
	
	public abstract void doUpdate(AbstractAdapter adapter, Object data);

	public void modelBoardCompleted(ModelBoardCompleteEvent event) {
		// TODO Auto-generated method stub
		
	}


	public void modelBoardCreated(ModelBoardCreateEvent event) {
		// TODO Auto-generated method stub
		
	}


	public void modelBoardUpdated(ModelBoardUpdateEvent event) {
		// TODO Auto-generated method stub
		
	}
	
	public void modelRuleSet(ModelBoardRuleSetEvent event)
	{
		
	}
	
	public void modelBoardReset(ModelBoardResetEvent event)
	{
	    
	}
}
